package com.senriot.quickup.service.mapper

import com.senriot.cloud.common.IEntityMapper
import com.senriot.quickup.domain.Order
import com.senriot.quickup.service.dto.OrderDTO
import org.mapstruct.Mapper
import org.mapstruct.Mapping
import org.mapstruct.Mappings
import org.mapstruct.NullValuePropertyMappingStrategy

@Mapper(componentModel = "spring", nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
abstract class OrderMapper : IEntityMapper<OrderDTO, Order>
{

    @Mappings(
            Mapping(target = "storeId", source = "store.id"),
            Mapping(target = "storeName", source = "store.name"),
            Mapping(target = "cityName", source = "city.name"),
            Mapping(target = "provinceName", source = "province.name"),
            Mapping(target = "deviceId", source = "device.id"),
            Mapping(target = "deviceName", source = "device.deviceName"),
            Mapping(target = "userName", source = "user.nickName")
    )
    abstract override fun toDto(entity: Order): OrderDTO
}
